﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using netDxf;
using netDxf.Blocks;
using netDxf.Collections;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Objects;
using netDxf.Tables;
using netDxf.Units;
using Attribute = netDxf.Entities.Attribute;
using Image = netDxf.Entities.Image;
using Point = netDxf.Entities.Point;
using Trace = netDxf.Entities.Trace;
using System.Threading;

namespace TestDxfDocument
{

    class _ToolholderswithrectangularshankforindexableinsertsA
    {
        public static void ToolholderswithrectangularshankforindexableinsertsA(Dictionary<string, Object> data)//细柄丝锥
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            dxf.Layers["0"].Lineweight = Lineweight.W25;

            //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);


            double scale = 2; //放大系数

            double h1 = Convert.ToDouble(data["hf"]) * scale;
            double b = Convert.ToDouble(data["b"]) * scale;
            double l3 = Convert.ToDouble(data["l3"]) * scale;
            double f = Convert.ToDouble(data["wf"]) * scale;
            double h2 = Convert.ToDouble(data["h"]) * scale;
            double l1 = Convert.ToDouble(data["lf"]) * scale;
            double l2 = Convert.ToDouble(data["lh"]) * scale;
            double s = Convert.ToDouble(data["s"]) * scale;
            double re = Convert.ToDouble(data["re"]) * scale;

            Vector2 v1 = new Vector2(0, 0);
            Vector2 v2 = new Vector2(v1.X, v1.Y + l3);
            Vector2 v3 = fun.Polar(v2, 170 * pi / 180, l3);
            Vector2 v4 = new Vector2(v3.X, v3.Y - l3);
            Vector2 v5 = new Vector2(v2.X - (f - b), v2.Y + (f - b) / Math.Tan(80 * pi / 180));
            Vector2 v6 = new Vector2(v5.X, v1.Y + l1);
            Vector2 v7 = new Vector2(v6.X - b, v6.Y);
            Vector2 v9 = new Vector2(v4.X, v4.Y + l3 * 1.11 / 8.15);
            Vector2 v8 = new Vector2(v7.X, v9.Y + (v4.X - v7.X) / Math.Tan(80 * pi / 180));
            Vector2 v10 = new Vector2(v7.X, v7.Y - l1 * 7.72 / 72.38);
            Vector2 v11 = new Vector2(v6.X, v10.Y);
            Vector2 v12 = new Vector2(v11.X, v11.Y - h2);
            Vector2 v13 = new Vector2(v10.X, v12.Y);
            Vector2 v14 = new Vector2(v1.X + b * 2, v1.Y + l3 * 0.42 / 8.15);
            Vector2 v15 = new Vector2(v14.X + h1 - s, v14.Y);
            Vector2 v16 = new Vector2(v15.X, v1.Y);
            Vector2 v17 = new Vector2(v16.X + s, v16.Y);
            Vector2 v18 = new Vector2(v17.X, v3.Y);
            Vector2 v19 = new Vector2(v16.X, v18.Y - l3 * 1.15 / 8.15);
            Vector2 v20 = new Vector2(v16.X, v4.Y);
            Vector2 v21 = new Vector2(v17.X, v20.Y);
            Vector2 v22 = new Vector2(v14.X, v8.Y);
            Vector2 v23 = new Vector2(v20.X, v22.Y);
            Vector2 v24 = new Vector2(v18.X - h1 * 0.37 / 12.94, v18.Y - h1 * 0.37 / 12.94 / ((v18.X - v19.X) / (v18.Y - v19.Y)));
            Vector2 v32 = new Vector2(v24.X, v1.Y + l2);
            Vector2 v25 = new Vector2(v32.X, v32.Y + l1 * 20.34 / 72.38/3);
            Vector2 v30 = new Vector2(v14.X, v25.Y);
            Vector2 v26 = new Vector2(v25.X - (v25.X - v30.X) / 5, v25.Y);
            Vector2 v27 = new Vector2(v26.X - (v25.X - v30.X) / 5, v25.Y);
            Vector2 v28 = new Vector2(v27.X - (v25.X - v30.X) / 5, v25.Y);
            Vector2 v29 = new Vector2(v28.X - (v25.X - v30.X) / 5, v25.Y);
            Vector2 v31 = new Vector2(v14.X, v32.Y);
            Vector2 v33 = new Vector2(v5.X, v31.Y);
            Vector2 v34 = new Vector2(v8.X, v33.Y);
            Vector2 v35 = new Vector2(v34.X - b * 2, v34.Y);
            Vector2 v36 = new Vector2(v35.X - f, v35.Y);
            Vector2 v37 = new Vector2(v36.X, v36.Y - f * 12.99 / 13.52);
            Vector2 v38 = new Vector2(v35.X - f * 1.63 / 13.52, v37.Y);
            Vector2 v39 = new Vector2(v35.X - f * 0.45 / 13.52, v35.Y - f * 0.45 / 13.52 / ((v35.X - v38.X) / (v35.Y - v38.Y)));
            Vector2 v40 = new Vector2(v35.X - f * 7.91 / 13.52, v39.Y);
            Vector2 v41 = new Vector2(v35.X - f * 8.2 / 13.52, v35.Y);
            Vector2 v42 = new Vector2(v41.X, v41.Y + l1 / 3);
            Vector2 v43 = new Vector2(v42.X + f * 9.52 / 13.52, v42.Y + f * 1.17 / 13.52);
            Vector2 v44 = new Vector2(v43.X - f * 0.53 / 13.52, v43.Y + f * 1.18 / 13.52);
            Vector2 v45 = new Vector2(v43.X - f * 0.9 / 13.52, v43.Y + f * 2.76 / 13.52);
            Vector2 v46 = new Vector2(v43.X - f * 2.16 / 13.52, v43.Y + f * 4.85 / 13.52);
            Vector2 v47 = new Vector2(v43.X - f * 3.28 / 13.52, v43.Y + f * 6.29 / 13.52);
            Vector2 v48 = new Vector2(v43.X - f * 5.11 / 13.52, v43.Y + f * 8.28 / 13.52);
            Vector2 v49 = new Vector2(v43.X - f * 6.62 / 13.52, v43.Y + f * 9.33 / 13.52);
            Vector2 v50 = new Vector2(v43.X - f * 7.98 / 13.52, v43.Y + f * 10.7 / 13.52);
            Vector2 v51 = new Vector2(v42.X, v42.Y + f * 13.18 / 13.52);
            Vector2 v52 = new Vector2(v42.X, v42.Y + f * 8.31 / 13.52);
            Vector2 v53 = new Vector2(v42.X + f * 2.93 / 13.52, v42.Y + f * 8.04 / 13.52);
            Vector2 v54 = new Vector2(v53.X, v42.Y + (v53.X - v42.X) / ((v43.X - v42.X) / (v43.Y - v42.Y)));
            Vector2 a1 = new Vector2(v2.X - l3 * 2.74 / 8.15, v2.Y + (v3.Y - v2.Y) / 2);
            Vector2 a2 = new Vector2(a1.X, a1.Y + 7);
            Vector2 a3 = new Vector2(a1.X, v4.Y - (v4.Y - v1.Y) / 2);
            Vector2 a4 = new Vector2(a3.X, a3.Y - 7);
            Vector2 a5 = new Vector2(v1.X, v2.Y - (v2.Y - v8.Y) / 2);
            Vector2 a6 = new Vector2(a5.X + 7, a5.Y);
            Vector2 a7 = new Vector2(v8.X + 1, a5.Y);
            Vector2 a8 = new Vector2(a7.X - 7, a7.Y);



            LwPolyline line1 = new LwPolyline();
            line1.Vertexes.Add(new LwPolylineVertex(v5));
            line1.Vertexes.Add(new LwPolylineVertex(v3));
            line1.Vertexes.Add(new LwPolylineVertex(v4));
            line1.Vertexes.Add(new LwPolylineVertex(v1));
            line1.Vertexes.Add(new LwPolylineVertex(v2));
            line1.Vertexes.Add(new LwPolylineVertex(v5));

            //倒角
            var arc1 = Pus.Fillet4LwPline(line1, 1, re);
            var arc2 = Pus.Fillet4LwPline(arc1, 3, re);
            var arc3 = Pus.Fillet4LwPline(arc2, 5, re);
            var arc4 = Pus.Fillet4LwPline(arc3, 7, re);
            fun.PolyFill(dxf, arc4, 0.3, contour);

            LwPolyline line2 = new LwPolyline();
            line2.Vertexes.Add(new LwPolylineVertex(v5));
            line2.Vertexes.Add(new LwPolylineVertex(v6));
            line2.Vertexes.Add(new LwPolylineVertex(v7));
            line2.Vertexes.Add(new LwPolylineVertex(v10));
            line2.Vertexes.Add(new LwPolylineVertex(v11));
            line2.Vertexes.Add(new LwPolylineVertex(v12));
            line2.Vertexes.Add(new LwPolylineVertex(v13));
            line2.Vertexes.Add(new LwPolylineVertex(v10));
            line2.Vertexes.Add(new LwPolylineVertex(v8));
            line2.Vertexes.Add(new LwPolylineVertex(v9));
            fun.PolyFill(dxf, line2, 0.3, contour);

            LwPolyline line3 = new LwPolyline();
            line3.Vertexes.Add(new LwPolylineVertex(v33));
            line3.Vertexes.Add(new LwPolylineVertex(v34));
            fun.PolyFill(dxf, line3, 0.3, contour);

            LwPolyline line4 = new LwPolyline();
            line4.Vertexes.Add(new LwPolylineVertex(v20));
            line4.Vertexes.Add(new LwPolylineVertex(v21));
            line4.Vertexes.Add(new LwPolylineVertex(v17));
            line4.Vertexes.Add(new LwPolylineVertex(v16));
            line4.Vertexes.Add(new LwPolylineVertex(v19));
            line4.Vertexes.Add(new LwPolylineVertex(v18));
            line4.Vertexes.Add(new LwPolylineVertex(v17));
            fun.PolyFill(dxf, line4, 0.3, contour);

            LwPolyline line5 = new LwPolyline();
            line5.Vertexes.Add(new LwPolylineVertex(v24));
            line5.Vertexes.Add(new LwPolylineVertex(v25));
            line5.Vertexes.Add(new LwPolylineVertex(v26));
            line5.Vertexes.Add(new LwPolylineVertex(v27));
            line5.Vertexes.Add(new LwPolylineVertex(v28));
            line5.Vertexes.Add(new LwPolylineVertex(v29));
            line5.Vertexes.Add(new LwPolylineVertex(v30));
            line5.Vertexes.Add(new LwPolylineVertex(v14));
            line5.Vertexes.Add(new LwPolylineVertex(v15));
            line5.Vertexes[1].Bulge = Math.Tan(-56 * pi / 180 / 4);
            line5.Vertexes[2].Bulge = Math.Tan(56 * pi / 180 / 4);
            line5.Vertexes[3].Bulge = Math.Tan(-56 * pi / 180 / 4);
            line5.Vertexes[4].Bulge = Math.Tan(56 * pi / 180 / 4);
            line5.Vertexes[5].Bulge = Math.Tan(-56 * pi / 180 / 4);
            fun.PolyFill(dxf, line5, 0.3, contour);

            LwPolyline line6 = new LwPolyline();
            line6.Vertexes.Add(new LwPolylineVertex(v32));
            line6.Vertexes.Add(new LwPolylineVertex(v31));
            line6.Vertexes.Add(new LwPolylineVertex(v22));
            line6.Vertexes.Add(new LwPolylineVertex(v23));
            fun.PolyFill(dxf, line6, 0.3, contour);

            LwPolyline line7 = new LwPolyline();
            line7.Vertexes.Add(new LwPolylineVertex(v41));
            line7.Vertexes.Add(new LwPolylineVertex(v40));
            line7.Vertexes.Add(new LwPolylineVertex(v39));
            line7.Vertexes.Add(new LwPolylineVertex(v35));
            line7.Vertexes.Add(new LwPolylineVertex(v36));
            line7.Vertexes.Add(new LwPolylineVertex(v37));
            line7.Vertexes.Add(new LwPolylineVertex(v38));
            line7.Vertexes.Add(new LwPolylineVertex(v35));
            fun.PolyFill(dxf, line7, 0.3, contour);

            LwPolyline line8 = new LwPolyline();
            line8.Vertexes.Add(new LwPolylineVertex(v54));
            line8.Vertexes.Add(new LwPolylineVertex(v53));
            line8.Vertexes.Add(new LwPolylineVertex(v52));
            line8.Vertexes.Add(new LwPolylineVertex(v42));
            line8.Vertexes.Add(new LwPolylineVertex(v43));
            line8.Vertexes.Add(new LwPolylineVertex(v44));
            line8.Vertexes.Add(new LwPolylineVertex(v45));
            line8.Vertexes.Add(new LwPolylineVertex(v46));
            line8.Vertexes.Add(new LwPolylineVertex(v47));
            line8.Vertexes.Add(new LwPolylineVertex(v48));
            line8.Vertexes.Add(new LwPolylineVertex(v49));
            line8.Vertexes.Add(new LwPolylineVertex(v50));
            line8.Vertexes.Add(new LwPolylineVertex(v51));
            line8.Vertexes.Add(new LwPolylineVertex(v42));
            line8.Vertexes[4].Bulge = Math.Tan(45 * pi / 180 / 4);
            line8.Vertexes[5].Bulge = Math.Tan(-41 * pi / 180 / 4);
            line8.Vertexes[6].Bulge = Math.Tan(59 * pi / 180 / 4);
            line8.Vertexes[7].Bulge = Math.Tan(-46 * pi / 180 / 4);
            line8.Vertexes[8].Bulge = Math.Tan(42 * pi / 180 / 4);
            line8.Vertexes[9].Bulge = Math.Tan(-35 * pi / 180 / 4);
            line8.Vertexes[10].Bulge = Math.Tan(32 * pi / 180 / 4);
            line8.Vertexes[11].Bulge = Math.Tan(-17 * pi / 180 / 4);
            fun.PolyFill(dxf, line8, 0.3, contour);

            Line line9 = new Line(a1, a2);
            line9.Linetype = Linetype.DashDot;
            line9.Lineweight = Lineweight.W25;
            line9.Layer = dimensioning;
            dxf.AddEntity(line9);

            Line line10 = new Line(a3, a4);
            line10.Linetype = Linetype.DashDot;
            line10.Lineweight = Lineweight.W25;
            line10.Layer = dimensioning;
            dxf.AddEntity(line10);

            Line line11 = new Line(a5, a6);
            line11.Linetype = Linetype.DashDot;
            line11.Lineweight = Lineweight.W25;
            line11.Layer = dimensioning;
            dxf.AddEntity(line11);

            Line line12 = new Line(a7, a8);
            line12.Lineweight = Lineweight.W25;
            line12.Layer = dimensioning;
            dxf.AddEntity(line12);



            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v11));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v12));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v10));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v11));
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 10, hline1, harc1, hatching);

            LwPolyline hatchpoly2 = new LwPolyline();
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v51));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v52));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v53));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v54));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v43));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v44));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v45));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v46));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v47));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v48));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v49));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v50));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v51));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v42));
            hatchpoly2.Vertexes[4].Bulge = Math.Tan(45 * pi / 180 / 4);
            hatchpoly2.Vertexes[5].Bulge = Math.Tan(-41 * pi / 180 / 4);
            hatchpoly2.Vertexes[6].Bulge = Math.Tan(59 * pi / 180 / 4);
            hatchpoly2.Vertexes[7].Bulge = Math.Tan(-46 * pi / 180 / 4);
            hatchpoly2.Vertexes[8].Bulge = Math.Tan(42 * pi / 180 / 4);
            hatchpoly2.Vertexes[9].Bulge = Math.Tan(-35 * pi / 180 / 4);
            hatchpoly2.Vertexes[10].Bulge = Math.Tan(32 * pi / 180 / 4);
            hatchpoly2.Vertexes[11].Bulge = Math.Tan(-17 * pi / 180 / 4);
            hatchpoly2.IsClosed = true;
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            Arc[] harc2 = new Arc[100];
            int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)hatchpoly2.Explode()[i];
                }
                if (htype2[i] == "Arc")
                {
                    harc2[i] = (Arc)hatchpoly2.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype2, hnumst2, 45, 10, hline2, harc2, hatching);

            LwPolyline hatchpoly3 = new LwPolyline();
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v41));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v40));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v39));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v38));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v37));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v36));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v41));
            hatchpoly3.IsClosed = true;
            String[] htype3 = new String[100];
            Line[] hline3 = new Line[100];
            Arc[] harc3 = new Arc[100];
            int hnumst3 = hatchpoly3.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst3; i++)
            {
                htype3[i] = hatchpoly3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype3[i] == "Line")
                {
                    hline3[i] = (Line)hatchpoly3.Explode()[i];
                }
                if (htype3[i] == "Arc")
                {
                    harc3[i] = (Arc)hatchpoly3.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype3, hnumst3, 45, 10, hline3, harc3, hatching);

            LwPolyline hatchpoly4 = new LwPolyline();
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v54));
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v53));
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v52));
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v42));
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v54));
            hatchpoly4.IsClosed = true;
            String[] htype4 = new String[100];
            Line[] hline4 = new Line[100];
            Arc[] harc4 = new Arc[100]; 
            int hnumst4 = hatchpoly4.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst4; i++)
            {
                htype4[i] = hatchpoly4.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype4[i] == "Line")
                {
                    hline4[i] = (Line)hatchpoly4.Explode()[i];
                }
                if (htype4[i] == "Arc")
                {
                    harc4[i] = (Arc)hatchpoly4.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype4, hnumst4, 100, 10, hline4, harc4, hatching);

            LwPolyline hatchpoly5 = new LwPolyline();
            hatchpoly5.Vertexes.Add(new LwPolylineVertex(v41));
            hatchpoly5.Vertexes.Add(new LwPolylineVertex(v40));
            hatchpoly5.Vertexes.Add(new LwPolylineVertex(v39));
            hatchpoly5.Vertexes.Add(new LwPolylineVertex(v35));
            hatchpoly5.Vertexes.Add(new LwPolylineVertex(v41));
            hatchpoly5.IsClosed = true;
            String[] htype5 = new String[100];
            Line[] hline5 = new Line[100];
            Arc[] harc5 = new Arc[100];
            int hnumst5 = hatchpoly5.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst5; i++)
            {
                htype5[i] = hatchpoly5.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype5[i] == "Line")
                {
                    hline5[i] = (Line)hatchpoly5.Explode()[i];
                }
                if (htype5[i] == "Arc")
                {
                    harc5[i] = (Arc)hatchpoly5.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype5, hnumst5, 100, 10, hline5, harc5, hatching);

            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 3.5;
            dimensionStyle.ExtLineExtend = 0.6;//标注延长线长度/2
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 3.5;
            double offset = 10;

            double height = 2;
            double arrowsize = 1;
            double exline = 2;



            Text txt1 = new Text("A-A", new Vector2 (v51.X ,v51.Y +5), 1.6, 0);
            dxf.AddEntity(txt1);

            Text txt2 = new Text("B-B", new Vector2(v51.X, v41.Y + 2.5), 1.6, 0);
            dxf.AddEntity(txt2);

            Text txt3 = new Text("A", new Vector2(a2.X, a2.Y +1), 1.6, 0);
            dxf.AddEntity(txt3);

            Text txt4 = new Text("A", new Vector2(a4.X, a4.Y - 4), 1.6, 0);
            dxf.AddEntity(txt4);

            Text txt5 = new Text("B", new Vector2(a8.X-3.5, a8.Y), 1.6, 0);
            dxf.AddEntity(txt5);

            Text txt6 = new Text("B", new Vector2(a6.X + 1, a6.Y), 1.6, 0);
            dxf.AddEntity(txt6);

            fun.jt(dxf, new Vector2(a2.X, a2.Y - 1.5), 0, offset/2, 3.5, "");

            fun.jt(dxf, new Vector2(a4.X, a4.Y + 1.5), 0, offset / 2, 3.5, "");

            fun.jt(dxf, new Vector2(a8.X+1.5, a8.Y), 90, offset / 2, 3.5, "");

            fun.jt(dxf, new Vector2(a6.X - 1.5, a6.Y), 90, offset / 2, 3.5, "");

            fun.dimrot1(dxf, v8, v1, 180, offset*2 + (v8.Y - v1.Y) / 2, 1, height, arrowsize, exline, "f=" + f / scale, "", "");

            fun.dimrot1(dxf, v4, v3, 90, offset*2 + (v3.X -v8.X ) / 2, 1, height, arrowsize, exline, "l3=" + l3 / scale, "", "");

            fun.dimrot1(dxf, v1, v33, -90, offset*2, 1, height, arrowsize, exline, "l2=" + l2 / scale, "", "");

            fun.dimrot1(dxf, v1, v6, -90, offset*3, 1, height, arrowsize, exline, "l1=" + l1 / scale, "", "");

            fun.dimrot1(dxf, v7, v6, 0, offset / 2, 1, height, arrowsize, exline, "b=" + b / scale, "", "");

            fun.dimrot1(dxf, v11, v12, -90, offset, 1, height, arrowsize, exline, "h2=" + h2 / scale, "", "");

            fun.dimrot1(dxf, v14, v17, 180, offset, 1, height, arrowsize, exline, "h1=" + h1 / scale, "", "");

            fun.jdbz2(dxf, new Line(v1, fun.Polar(v1, 90 * pi / 180, 0.1)), new Line(v1, fun.Polar(v1, 170 * pi / 180, 0.1)), l3/2, height, arrowsize, exline, "80°", "", "");

            fun.jdbz2(dxf, new Line(v1, fun.Polar(v1, 0 * pi / 180, 0.1)), new Line(v1, fun.Polar(v1, 90 * pi / 180, 0.1)), l3 / 2, height, arrowsize, exline, "90°", "", "");


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            Vector2 p0 = new Vector2(0, 0);

            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }





            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);


            //定义格式，路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);


        }

    }
}
